package study.itheima.dao;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import study.itheima.domain.Orders;
import study.itheima.domain.User;

import java.util.List;

public interface UsersMap {
    @Select("select * from user")
    @Results(id="UsersMap",value = {
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "username",property = "username"),
            @Result(property = "list",javaType = List.class,column = "id",many = @Many(select = "study.itheima.dao.OrdersMap.findById",fetchType = FetchType.LAZY))
    })
    List<User> findAll();
}
